package com.example.mqtt.handler;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.springframework.kafka.support.ProducerListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class KafkaSendResultHandler implements ProducerListener {

    @Override
    public void onSuccess(String topic, Integer partition, Object key, Object value, RecordMetadata recordMetadata) {
        log.info("onSuccess --->> topic:{} key:{}",topic,key);
    }

    @Override
    public void onError(String topic, Integer partition, Object key, Object value, Exception exception) {
        log.error("onError--->> topic:{}key:{}",topic,key);
        exception.printStackTrace();
    }

    @Override
    public boolean isInterestedInSuccess() {
        return false;
    }
}
